Present invention embodiments relate to database technology, and more specifically, to a column-oriented partial sort for data that may include compressed columns.
Database systems often have to sort the results of a query based on one or more columns to produce a limited number of results. For example, to find the ten customers that account for the most profit, a company's database system may compute the profit for each customer, sort the customers by those numbers, and keep only the top ten results. This operation is referred to as a “partial sort” or “top N sort.”
In a column-oriented database system, sets of records may be represented as separate streams of data, one stream per column of data. The data in the streams may be in compressed forms. A column-oriented database system may perform a partial sort by decompressing the data, transposing the data into row-oriented record form, and applying a conventional partial sort algorithm to the transposed data. However, this approach incurs the overhead of decompressing and transposing the data.